﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Generator
{
    /// <summary>
    /// contains a set of parameters for the Rota-generating engine
    /// </summary>
    /// <remarks>
    /// those parameters are available for customization by the application user (in run-Time)
    /// </remarks>
    public class Parameters
    {
        public byte StoreAssistantsMaximumHours
        {
            get { return _storeAssistantsMaximumHours; }
            set { _storeAssistantsMaximumHours = value; }
        }
        public byte StoreRunnersMaximumHours
        {
            get { return _storeRunnersMaximumHours; }
            set { _storeRunnersMaximumHours = value; }
        }
        /// <summary>
        /// maximum number of hours a store assistant can work. 0 = no maximum. (by default 40)
        /// </summary>
        /// <remarks>
        /// for any Soution that exceeds this limit, the Solution.Flawed property will be lit up (set true)
        /// </remarks>
        private byte _storeAssistantsMaximumHours;

        

        /// <summary>
        /// maximum number of hours a store runner can work. 0 = no maximum. (by default there'pShift no maximum)
        /// </summary>
        /// <remarks>
        /// for any Solution that exceeds this limit, the Solution.Flawed property will be lit up (set true)
        /// </remarks>
        private byte _storeRunnersMaximumHours;

        

        /// <summary>
        /// avoid giving somebody too many full Shifts in a row
        /// </summary>
        /// <remarks>
        /// the maximum is defined by MaximumFullShiftsInARow
        /// </remarks>        
        private byte _maximumFullShiftsInARow;

        public byte MaximumFullShiftsInARow
        {
            get { return _maximumFullShiftsInARow; }
            set { _maximumFullShiftsInARow = value; }
        }

        public bool MaximumShiftsInARowSpecified
        {
            get { return MaximumFullShiftsInARow > 0; }
        }

        private bool _splitWeekendsFairly;

        public bool SplitWeekendsFairly
        {
            get { return _splitWeekendsFairly; }
            set { _splitWeekendsFairly = value; }
        }
        private bool _keyFlowOptimizationOn;

        public bool KeyFlowOptimizationOn
        {
            get { return _keyFlowOptimizationOn; }
            set { _keyFlowOptimizationOn = value; }
        }
        private bool _assistantsConsideredForKeyFlow;

        public bool AssistantsConsideredForKeyFlow
        {
            get { return _assistantsConsideredForKeyFlow; }
            set { _assistantsConsideredForKeyFlow = value; }
        }
        private bool _penalizeOverdays;

        public bool PenalizeOverdays
        {
            get { return _penalizeOverdays; }
            set { _penalizeOverdays = value; }
        }


        private bool _considerPreviousWeek;

        public bool ConsiderPreviousWeek
        {
            get { return _considerPreviousWeek; }
            set { _considerPreviousWeek = value; }
        }
        private SpeedMode _speed;

        public SpeedMode Speed
        {
            get { return _speed; }
            set { _speed = value; }
        }

        internal Int64[] LastWeekClosers;

        public static Parameters GetDefaultParameters()
        {
            var result = new Parameters();
            result.StoreRunnersMaximumHours = Generator.Settings.Default.DEFAULT_StoreRunnersMaximumHours;
            result.StoreAssistantsMaximumHours = Generator.Settings.Default.DEFAULT_StoreAssistantsMaximumHours;            
            result.MaximumFullShiftsInARow = Generator.Settings.Default.DEFAULT_MaximumFullShiftsInARow;
            result.SplitWeekendsFairly = Generator.Settings.Default.DEFAULT_SplitWeekendsFairly;
            result.KeyFlowOptimizationOn = Generator.Settings.Default.DEFAULT_KeyFlowOptimizationOn;
            result.AssistantsConsideredForKeyFlow = Generator.Settings.Default.DEFAULT_AssistantsConsideredForKeyFlow;
            result.PenalizeOverdays = Generator.Settings.Default.DEFAULT_PenalizeOverdays;
            switch (Generator.Settings.Default.DEFAULT_Speed)
            {
                case 1:
                    {
                        result.Speed = SpeedMode.Express;
                        break;
                    }
                case 2:
                    {
                        result.Speed = SpeedMode.Fast;
                        break;
                    }
                case 3:
                    {
                        result.Speed = SpeedMode.Slow;
                        break;
                    }
                default: // 0 (SpeedMode.None) or invalid value
                    {
                        result.Speed = SpeedMode.Fast;
                        break;
                    }
            }
            return result;
        }
    }
}
